<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2019 广东卓锐软件有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------

namespace plugins\DevTeam;

use app\common\controller\Plugin;

/**
 * 后台首页统计
 * @package plugins\DevTeam
 */
class DevTeam extends Plugin
{
    /**
     * @var array 插件信息
     */
    public $info = [
        // 插件名[必填]
        'name'        => 'DevTeam',
        // 插件标题[必填]
        'title'       => '后台首页统计',
        // 插件唯一标识[必填],格式：插件名.开发者标识.plugin
        'identifier'  => 'dev_team.dch.plugin',
        // 插件图标[选填]
        'icon'        => 'fa fa-fw fa-users',
        // 插件描述[选填]
        'description' => '在后台首页显示统计信息',
        // 插件作者[必填]
        'author'      => 'DCH',
        // 作者主页[选填]
        'author_url'  => '',
        // 插件版本[必填],格式采用三段式：主版本号.次版本号.修订版本号
        'version'     => '1.0.0',
        // 是否有后台管理功能[选填]
        'admin'       => '0',
    ];

    /**
     * @var array 插件钩子
     */
    public $hooks = [
        'admin_index',
        'page_plugin_css',
        'page_plugin_js',
    ];

    /**
     * 后台首页钩子
     */
    public function adminIndex()
    {
        $config = $this->getConfigValue();
        if ($config['display']) {
            $this->fetch('widget', $config);
        }
    }

    public function pagePluginCss()
    {
        $libs = config('template.tpl_replace_string')['__LIBS__'];
        //$plugins = explode('/public/',PUBLIC_PATH)[0].config('template.tpl_replace_string')['__PLUGINS__'].'/'.$this->info['name'];
        $plugins = config('template.tpl_replace_string')['__PLUGINS__'].'/'.$this->info['name'];
        $css = <<<eof
<link rel="stylesheet" href="{$libs}/bootstrap-daterangepicker/daterangepicker.css">
<style>.date{padding: 8px 8px 8px 8px;font-size: 16px;color: rgba(0, 0, 0, 1);}.date-active {color: #ff6b6b;}.stat{height: 160px;}.stat-pointer{cursor: pointer;}.stat-bordered{display: flex;justify-content: space-between;margin-bottom: 10px;}.stat-kh{background-image: url('{$plugins}/static/img/khstat.png');background-repeat: no-repeat;background-size: 100% 100%;margin-right: 20px;}.stat-dd{background-image: url('{$plugins}/static/img/ddstat.png');background-repeat: no-repeat;background-size: 100% 100%;margin-right: 20px;}.stat-je{background-image: url('{$plugins}/static/img/jestat.png');background-repeat: no-repeat;background-size: 100% 100%;margin-right: 20px;}.stat-xs{background-image: url('{$plugins}/static/img/xsstat.png');background-repeat: no-repeat;background-size: 100% 100%;}.stat-title{color: #fff;margin-top: 45px;margin-left: 20px;margin-right: 20px;}.stat-content{color: #fff;margin-top: 10px;margin-left: 20px;font-size: 18px;}.border-bottom{border-bottom: inherit;padding: 10px 4px 0px;}.push1{margin-bottom: 5px;}</style>
eof;

        echo $css;
    }

    public function pagePluginJs()
    {
        $libs = config('template.tpl_replace_string')['__LIBS__'];
        $js = <<<eof
<script src="{$libs}/bootstrap-datetimepicker/moment.min.js?v=20180327"></script>
<script src="{$libs}/bootstrap-daterangepicker/daterangepicker.js?v=20180327"></script>
eof;

        echo $js;
    }

    /**
     * 安装方法
     * @return bool
     */
    public function install(){
        return true;
    }

    /**
     * 卸载方法必
     * @return bool
     */
    public function uninstall(){
        return true;
    }
}
